//
//  CommonView_iPad.m
//  WRY
//
//  Created by zhong sckj on 10-10-14.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CommonView_iPad.h"


@implementation CommonView_iPad
- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
		
    }
    return self;
}
- (void)showConnectionError {
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
													message:@"Connection error" 
												   delegate:nil
										  cancelButtonTitle:@"OK" 
										  otherButtonTitles:nil];
	[alert show];
	[alert release];
}
- (void)showLoading {
	if (loadingLabel == nil) {
		float centerX ;
		float centerY;
		centerX = self.frame.size.width/2;
		centerY =self.frame.size.height/2; 
		CGPoint center = CGPointMake(centerX, centerY);
		loadingBackImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"but90x30.png"]];
		loadingBackImage.frame = CGRectMake(0.0f, 0.0f, 90.0f, 30.0f);
		loadingBackImage.center = center;
		[self addSubview:loadingBackImage];
		
		loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 90.0f, 30.0f)];
		loadingLabel.font = [UIFont boldSystemFontOfSize:12.0f];
		loadingLabel.backgroundColor = [UIColor clearColor];
		loadingLabel.text = @"加载中...";
		loadingLabel.textColor = [UIColor darkGrayColor];
		loadingLabel.center = CGPointMake(centerX+32, centerY);
		[self addSubview:loadingLabel];
		activeIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
		activeIndicator.center = CGPointMake(centerX - 28, centerY);
		[self addSubview:activeIndicator];
		
	}
	self.userInteractionEnabled = NO;
	loadingBackImage.hidden = NO;
	activeIndicator.hidden = NO;
	[activeIndicator startAnimating];
	loadingLabel.hidden = NO;
	[self bringSubviewToFront:loadingBackImage];
	[self bringSubviewToFront:activeIndicator];
	[self bringSubviewToFront:loadingLabel];
}
- (void)hideLoading {
	[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
	self.userInteractionEnabled = YES;
	loadingBackImage.hidden = YES;
	activeIndicator.hidden = YES;
	[activeIndicator stopAnimating];
	loadingLabel.hidden = YES;
}

- (void)dealloc {
	[loadingLabel release];
	[activeIndicator release];
	[loadingBackImage release];
    [super dealloc];
}


@end
